﻿$("#exampleAccordion>li:nth-child(3) a").removeClass("collapsed");
$("#exampleAccordion>li:nth-child(3) ul").addClass("show");
$("#exampleAccordion>li:nth-child(3) ul>li:nth-child(1)").addClass("active");
$(function () {
    var columns = [{ "data": "ProNo" }, { "data": "Name" }, { "data": "Money" }, { "data": "PV" }, {
        "data": "UnSale", render: function (value, type, row) {
            if (row.UnSale) {
                return '<a href="javascript:void(0)" onclick="show(this,&apos;' + row.ProNo + '&apos;)">已下架</a>'
            } else {
                return '<a href="javascript:void(0)" onclick="show(this,&apos;' + row.ProNo + '&apos;)">已上架</a>'
            }
        }
    }, { "data": "AddDT" }, { "data": "ProNo", render: function (value, type, row) { return '<a href="javascript:void(0)" class="btn btn-danger btn-sm" onclick="Product(&apos;' + row.ProNo + '&apos;)">删除</a>' } }]
    dataTable.dataTables("/Product/ProcudtPage", columns, false);
    $("#dataTable_wrapper .row:last-child").addClass("mt-2");
})
//上下架
function show(t,id) {
    $.post("/Product/UnSale", { proNo: id }, function (data) {
        layer.msg("修改成功");
        $(t).text(data.Msg);
    })
}


//产品删除
function Product(id) {
    var option = {
		url: "/Product/DelPro",
        type: "post",
        data: { proNo: id },
        callback: SetMode
	}

	swGather.swAjax(option);
}
//ajax回调
function SetMode(data) {
    layer.msg(data.Msg);
    setTimeout(function () {
        location.reload();
    },1000)
}